#include "StdAfx.h"
#include "ExtrudeEditor.h"
#include "EditorHelper.h"
#include "FunctionDriverExtrude.h"
REGISTERE_EDITOR(CExtrudeEditor);

CExtrudeEditor::CExtrudeEditor(void)
{

}

CExtrudeEditor::~CExtrudeEditor(void)
{

}
CString CExtrudeEditor::GetID(void)
{
	return EXTRUDE_GUID;
}

CExtrudeInfo* CExtrudeEditor::GetShapeInfo()
{
	return &m_Info;
}

void CExtrudeEditor::Initialize(CAnyView* pView)
{
	m_Info.Reset();

	AddSubEditor(new CShapeCapture(TopAbs_EDGE,m_Info.pShape, m_ptCapturePoint), 
		CExtrudeInfo::SHAPE);
	AddSubEditor(new CHeightCapture(m_ptCapturePoint, m_ptEnd, m_Info.dHeight),
		CExtrudeInfo::HEIGHT);

	CModelEditor::Initialize(pView);

	m_Info.dirNormal = pView->CurPlaneNormal();
}


bool CExtrudeEditor::CreatePreviewShape()
{
	if(CurrentStep() == CExtrudeInfo::SHAPE)   
		return false;

	TopoDS_Shape shape;
	CExtrudeBuilder builder;
	if(builder.Build(&m_Info, shape))
	{
		SetPreviewShape(shape);
		return true;
	}

	return false;

}

bool CExtrudeEditor::CreateShapeLabel(TDF_Label& label)
{
	if(m_Info.pShape.IsNull())
		return false;

	label = NewLabel(_T("Extrude"));
	m_Info.AddToLabel(label);

	Handle(CFunctionDriverExtrude) functionDriver;
	return ProcessFunctionDriver<CFunctionDriverExtrude>(label, functionDriver);
}